package com.itheima.tlias.mapper;

import com.itheima.tlias.pojo.Emp;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {

	//分页查询
	//@Select("select e.* ,d.name as deptName from emp e  left join dept d on e.dept_id = d.id")
	List<Emp> list(String name, Integer gender, LocalDate begin, LocalDate end);

	@Options(useGeneratedKeys = true, keyProperty = "id")
	@Insert("insert into emp( username, name, gender, phone, job, salary, image, entry_date, dept_id, create_time, update_time) "
			+ "values (#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
	void save(Emp emp);

	//查询所有员工
	@Select("select * from emp")
	List<Emp> listAll();

	void deleteByIds(List<Integer> ids);

	Emp infoById(Integer id);

	void update(Emp emp);

	@MapKey("pos")
	List<Map<String, Object>> getJobData();

	@MapKey("name")
	List<Map<String, Object>> getGenderData();

	@Select("select * from emp where username=#{username} and password=#{password}")
	Emp getEmpByUsernameAndPassword(Emp emp);
}
